<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 当网页中所有的html标签, css样式, 外部图片加载完毕之后, 自动触发
        window.onload = function () {
            var title = document.querySelector('#title')
            console.log(title);
            title.style.background = 'lightgreen'
            title.style.padding = '10px'
        }
    </script>
</head>

<body>
    <h1 id="title">这是一个标题</h1>
</body>

</html>